<template>
    <view class="content">
        <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" >
            <view v-for="(item,index) in messageList" :key="index" class="text-area">
               <MessageItem :item="item" class="message-li"></MessageItem>
            </view>
        </scroll-view>
        <view class="add-message">
            +
        </view>
    </view>
  </template>
  
  <script>
 import MessageItem from '../components/message/MessageItem.vue';
 import {getMessageList} from '@/http/message/index'
  export default {
    components:{
        MessageItem
    },
    data() {
      return {
        title: '留言板',
        scrollTop:0,
        messageList:[
         {
            userName:"张三",
            text:"你好啊，张三！",
            time:"2020-01-01 12:00:00",
         },
         {
            userName:"李四",
            text:"你好啊，李四！",
            time:"2020-01-01 12:00:00",
         },
        ]
      }
    },
   onLoad() {
       getMessageList({pageIndex:1,pageSize:10}).then(res=>{
        console.log(res)
        if(res.data.code===200){
            this.messageList = this.messageList.concat(res.data.data)
        }
       })
    },
    methods: {},
  }
  </script>
  
  <style scoped lang="less">
  .content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f3f3f3;
  }
  .text-area {
    display: flex;
    justify-content: center;
   .message-li{
        width: 100%;
    }
  }
  
  .title {
    font-size: 36rpx;
    color: #8f8f94;
  }
  .add-message{
    position: fixed;
    bottom: 20rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 120rpx;
    height: 120rpx;
    border-radius: 50%;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    font-size: 72rpx;
    text-align: center;
    line-height: 110rpx;
    animation: 1s ease;
  }
  </style>
  